package weaver.interfaces.jjy.duss.action;

import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/*
 *@Description: 福利人员上报提交接口
 *@Author: Dusongsong
 *@Date: 2019/12/24
 */
public class WeaHRflryjxAction extends BaseBean implements Action {
    @Override
    public String execute(RequestInfo requestInfo) {
        RecordSet rs = new RecordSet();
        RecordSet rs2 = new RecordSet();
        BaseBean baseBean = new BaseBean();
        String requestid = requestInfo.getRequestid();
        baseBean.writeLog("请求ID" + requestid);
        baseBean.writeLog("调用: WeaHRflryjxAction");
        String tablename = requestInfo.getRequestManager().getBillTableName();//主表
        rs.executeQuery("select * from " + tablename + " where requestid=?", requestid);
        baseBean.writeLog("select * from " + tablename + " where requestid=" + requestid);
        rs.next();
        String mainid = Util.null2String(rs.getString("id"));//外键
        String STATE = "1";
        String SQL = "select numid  from " + tablename + "_dt1 where mainid='" + mainid + "'";
        baseBean.writeLog(SQL);
        rs.execute(SQL);
        try{
        while (rs.next()) {
            String NUMID = Util.null2String(rs.getString("numid"));//唯一标识
            rs2.execute("select flfw1,flkh from " + tablename + "_dt1 where mainid='" + mainid + "' and numid='" + NUMID + "'");
            rs2.next();
            baseBean.writeLog("调用SQL：" + "select flfw1,flkh from " + tablename + "_dt1 where mainid='" + mainid + "' and  numid='" + NUMID + "'");
            String FLFW1 = Util.null2String(rs2.getString("FLFW1"));//部门上报福利范围
            String FLKH = Util.null2String(rs2.getString("FLKH"));//福利卡号
            rs2.executeUpdate("update uf_sxflrymdxf set flfw1='" + FLFW1 + "' ,flkh1= '" + FLKH + "', zt='" + STATE + "' where  numid='" + NUMID + "'");
            baseBean.writeLog("执行语句：" + "update uf_sxflrymdxf set flfw1='" + FLFW1 + "' ,flkh1= '" + FLKH + "', zt='" + STATE + "' where  numid='" + NUMID + "'");
        }
        return Action.SUCCESS;
    } catch (Exception e) {
        e.printStackTrace();
        baseBean.writeLog("异常参考:" + e);
        requestInfo.getRequestManager().setMessageid("111111");
        requestInfo.getRequestManager().setMessagecontent(e.getMessage());
        return Action.FAILURE_AND_CONTINUE;
    }
    }
}

